function useTimeline() {

  const getViewExtend = () => {
    let params = {};
    let extend = viewer.camera.computeViewRectangle();
    if (typeof extend === "undefined") {
      //2D下会可能拾取不到坐标，extend返回undefined,因此作如下转换
      let canvas = viewer.scene.canvas;
      let upperLeft = new Cesium.Cartesian2(0, 0); //canvas左上角坐标转2d坐标
      let lowerRight = new Cesium.Cartesian2(canvas.clientWidth, canvas.clientHeight); //canvas右下角坐标转2d坐标

      let ellipsoid = viewer.scene.globe.ellipsoid;
      let upperLeft3 = viewer.camera.pickEllipsoid(upperLeft, ellipsoid); //2D转3D世界坐标

      let lowerRight3 = viewer.camera.pickEllipsoid(lowerRight, ellipsoid); //2D转3D世界坐标

      let upperLeftCartographic = viewer.scene.globe.ellipsoid.cartesianToCartographic(
        upperLeft3
      ); //3D世界坐标转弧度
      let lowerRightCartographic = viewer.scene.globe.ellipsoid.cartesianToCartographic(
        lowerRight3
      ); //3D世界坐标转弧度

      let minx = Cesium.Math.toDegrees(upperLeftCartographic.longitude); //弧度转经纬度
      let maxx = Cesium.Math.toDegrees(lowerRightCartographic.longitude); //弧度转经纬度

      let miny = Cesium.Math.toDegrees(lowerRightCartographic.latitude); //弧度转经纬度
      let maxy = Cesium.Math.toDegrees(upperLeftCartographic.latitude); //弧度转经纬度
      params.minx = minx;
      params.maxx = maxx;
      params.miny = miny;
      params.maxy = maxy;
    } else {
      //3D获取方式
      params.maxx = Cesium.Math.toDegrees(extend.east);
      params.maxy = Cesium.Math.toDegrees(extend.north);

      params.minx = Cesium.Math.toDegrees(extend.west);
      params.miny = Cesium.Math.toDegrees(extend.south);
    }
    // 返回屏幕所在经纬度范围
    return params;
  };

  // 获取当前地图瓦片级别
  function tileLevel() {
    let tiles = new Set();
    let tilesToRender = viewer.scene.globe._surface._tilesToRender;
    if (Cesium.defined(tilesToRender)) {
      for (let i = 0; i < tilesToRender.length; i++) {
        tiles.add(tilesToRender[i].level);
      }
      console.log("当前地图瓦片级别为:");
      console.log(tiles);
      return tiles;
    }
  }

  function getparams() {
    let level = tileLevel();

    level = Array.from(level)[0];

    let bbox = getViewExtend();

    // {minx: 121.38127281980341, maxx: 121.61098262268831, miny: 25.00032616721884, maxy: 25.06911946756198}

    bbox = [
      [bbox.minx, bbox.miny],
      [bbox.minx, bbox.maxy],
      [bbox.maxx, bbox.maxy],
      [bbox.maxx, bbox.miny],
      [bbox.minx, bbox.miny],
    ];

    let geojson = [
      bbox
        .map((item) => {
          return item.join(" ");
        })
        .join(","),
    ];

    return {
      level,
      geojson,
    };
  }



  function aaa(params) {
    let sousuoparams = {
      timeRange: "", //时间范围（:分隔）
      sensor: "", //传感器（,分隔）
      wxName: "", //卫星名称
      sunCorner: "", //太阳角
      geojson: [], //矩形框四角点
      shpPath: "", //矢量文件导入
      level: "", //分辨率
    };

    let params = getparams();
    sousuoparams.level = params.level;
    sousuoparams.geojson = params.geojson;

    console.log(params);

    // return
    apiList.getLineSearch(params).then((res) => {
      // dataList.value = res.data;
    });
  }

  function dragEventDis() {
    handler.destroy()
  }

  let handler = {};
  function dragEvent() {
    // 获取Viewer的ScreenSpaceEventHandler
    handler = window.viewer.screenSpaceEventHandler;

    let ldown = false

    // 监听拖拽开始事件
    handler.setInputAction(function (event) {
      ldown = true
    }, Cesium.ScreenSpaceEventType.LEFT_DOWN);

    // 监听拖拽移动事件
    handler.setInputAction(function (event) {
      if (ldown) {
        demoveend()
      }
    }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);

    // 监听拖拽结束事件
    handler.setInputAction(function (event) {
      ldown = false
    }, Cesium.ScreenSpaceEventType.LEFT_UP);
  }

  return {
    getparams
  }
}

export default useTimeline